import z from "zod";
import i18n from "@/i18n";

const forgot = {
  email: z
    .email({
      message: i18n.t("Invalid email", { defaultValue: "Invalid email" }),
    })
    .min(1, {
      message: i18n.t("Email is required", {
        defaultValue: "Email is required",
      }),
    }),
  captcha: z.string().min(1, {
    message: i18n.t("Captcha is required", {
      defaultValue: "Captcha is required",
    }),
  }),
  captcha_id: z.string().min(1, {
    message: i18n.t("Captcha ID is required", {
      defaultValue: "Captcha ID is required",
    }),
  }),
};

export const ForgotSchema = () => z.object(forgot);

export type ForgotFormData = z.infer<ReturnType<typeof ForgotSchema>>;

export const VerifyForgotSchema = () =>
  z.object({
    ...forgot,
    token: z.string().min(1, {
      message: i18n.t("Verification token required", {
        defaultValue: "Verification token required",
      }),
    }),
    password: z.string().min(6, {
      message: i18n.t("Invalid password", { defaultValue: "Invalid password" }),
    }),
  });

export type VerifyForgotFormData = z.infer<ReturnType<typeof VerifyForgotSchema>>;
